#include "NamedPipeServer.h"
#include <iostream>

using namespace std;

int main(){
	NamedPipeServer *n=new NamedPipeServer("\\\\.\\pipe\\OAO");


for(;;){

	while(n->IsDataAvailable())
	{
	std::string message;
		if(n->Read(message))
		{
				cout<<message<<endl;
		}		
	}
	if(TRUE == n->IsBroken()){
		delete n;
		n = new NamedPipeServer("\\\\.\\pipe\\OAO");
	}

}

	cout<<"OAO"<<endl;
	getchar();
}